/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.movieSystem.view;
import com.movieSystem.model.UserInfo;
import javafx.application.Platform;
import javafx.stage.Stage;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class FrmUser extends javax.swing.JFrame {
    /**
     * Creates new form FrmUser
     */
	String userName;
	String password;
	String isadmin;
	public FrmUser self;
    static boolean first=true;
    Stage movieTime;
    public FrmUser(Stage movieTime1) {
        movieTime=movieTime1;
        initComponents();
        self=this;
        this.userName= UserInfo.getUsername();
        this.password=UserInfo.getPassword();
        this.isadmin=UserInfo.getIsAdmin();
        TextFUsername.setText(userName);
        TextFStatus.setText(isadmin);
        TextFUsername.setEnabled(false);
        TextFStatus.setEnabled(false);
        this.setAlwaysOnTop(true);
    }
   




//    public FrmUser(String username,String status) {
//    	initComponents();
//    	this.username=username;
//    	
//        TextFUsername.setText(username);
//        TextFStatus.setText(status);
//        TextFUsername.setEnabled(false);
//        TextFStatus.setEnabled(false);
//        
//    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {



        DialogBalance = new javax.swing.JDialog();
        Label1 = new javax.swing.JLabel();
        TextFUsername = new javax.swing.JTextField();
        Label2 = new javax.swing.JLabel();
        TextFStatus = new javax.swing.JTextField();
        BtnPasswordChange = new javax.swing.JButton();
        BtnBalanceQuery = new javax.swing.JButton();
        BtnMyOrder = new javax.swing.JButton();
        BtnLogout = new javax.swing.JButton();

        javax.swing.GroupLayout DialogBalanceLayout = new javax.swing.GroupLayout(DialogBalance.getContentPane());
        DialogBalance.getContentPane().setLayout(DialogBalanceLayout);
        DialogBalanceLayout.setHorizontalGroup(
            DialogBalanceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        DialogBalanceLayout.setVerticalGroup(
            DialogBalanceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        this.addWindowListener(new WindowAdapter()
        {
            public void windowClosed(WindowEvent e)
            {
                first=true;
            }
        });
        setTitle("用户界面");

        Label1.setText("用户名:");

        TextFUsername.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TextFUsernameActionPerformed(evt);
            }
        });

        Label2.setText("身  份:");

        TextFStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TextFStatusActionPerformed(evt);
            }
        });

        BtnPasswordChange.setText("修改密码");
        BtnPasswordChange.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnPasswordChangeActionPerformed(evt);
            }
        });

        BtnBalanceQuery.setText("余额查询");
        BtnBalanceQuery.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                BtnBalanceQueryActionPerformed(e);
            }
        });

        BtnMyOrder.setText("我的订单");
        BtnMyOrder.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                BtnMyOrderActionPerformed(e);
            }
        });

        BtnLogout.setText("退出登录");
        BtnLogout.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                BtnLogoutActionPerformed(e);
            }
        });
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(BtnMyOrder)
                        .addGap(18, 18, 18)
                        .addComponent(BtnLogout))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(BtnPasswordChange)
                        .addGap(18, 18, 18)
                        .addComponent(BtnBalanceQuery))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Label1)
                            .addComponent(Label2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TextFUsername)
                            .addComponent(TextFStatus))))
                .addContainerGap(30, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Label1)
                    .addComponent(TextFUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Label2)
                    .addComponent(TextFStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnPasswordChange)
                    .addComponent(BtnBalanceQuery))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BtnMyOrder)
                    .addComponent(BtnLogout))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        pack();
        setLocationRelativeTo(null);
        setSize(new Dimension(500,300));
    }// </editor-fold>//GEN-END:initComponents

    private void TextFUsernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextFUsernameActionPerformed
        
    }//GEN-LAST:event_TextFUsernameActionPerformed

    private void TextFStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TextFStatusActionPerformed
        
    }//GEN-LAST:event_TextFStatusActionPerformed

    private void BtnPasswordChangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnPasswordChangeActionPerformed
        FrmChange fchange=new FrmChange(this);
        fchange.setVisible(true);
    }//GEN-LAST:event_BtnPasswordChangeActionPerformed

    private void BtnLogoutActionPerformed(java.awt.event.ActionEvent evt) {
    	//返回登录界面
        FrmLogin flogin=new FrmLogin();
        flogin.setVisible(true);
        Platform.runLater(()-> {movieTime.close();});
        //关闭当前界面
        self.dispose();
    }

    private void BtnMyOrderActionPerformed(java.awt.event.ActionEvent evt) {
        FrmOrders frmOrders = new FrmOrders();
        frmOrders.setVisible(true);
    }
    private void BtnBalanceQueryActionPerformed(java.awt.event.ActionEvent evt) {
    	//打开余额界面
        FrmBalance fbalance=new FrmBalance(this);
        fbalance.setVisible(true);       
    }
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(FrmUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(FrmUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(FrmUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(FrmUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new FrmUser().setVisible(true);
//
//            }
//        });
//    }



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BtnBalanceQuery;
    private javax.swing.JButton BtnLogout;
    private javax.swing.JButton BtnMyOrder;
    private javax.swing.JButton BtnPasswordChange;
    private javax.swing.JDialog DialogBalance;
    private javax.swing.JLabel Label1;
    private javax.swing.JLabel Label2;
    private javax.swing.JTextField TextFStatus;
    private javax.swing.JTextField TextFUsername;
    // End of variables declaration//GEN-END:variables
}
